<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${aier_title}</title>
<meta content="${aier_keywords}" name="keywords">
<meta content="${aier_description}" name="description">
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}text.css" />
<link rel="stylesheet"
	href="${aier_css_url}${aier_jqui_css}enhanced.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}school/sm.css" />
<link rel="stylesheet" href="${aier_css_url}school/si.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/dialog.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript"
	src="${aier_js_url}${aier_jqui_js}custominput.js"></script>
<script type="text/javascript"
	src="${aier_js_url}${aier_jqui_js}text.js"></script>
<title>管理员维护</title>
</head>
<script type="text/javascript">
$(document).ready(function(){
	$("#userinfo").jqGrid({                
		url:'${aier_url}${aier_urijs}admin_user_searchUser${aier_suffix}',                
		datatype:"json",                
		mtype:'GET',
		height:'230',
		width:'960',              
		colNames:['帐号','昵称','姓名','出生日期','性别','修改密码','uid'],                
		colModel:[                    
		{name:'account',index:'account',width:120,align:'center'},                    
		{name:'nickname',index:'nickname',width:100,align:'center'},                    
		{name:'realname',index:'realname',width:80,align:'center'},
		{name:'birthday',index:'birthday',width:80,align:'center'},
		{name:'sexStr',index:'sexStr',width:80,align:'center'},
		{name:'revoked',index:'revoked',width:80,align:'center', sortable:false},
		{name:'uid',index:'uid',hidden : true},
		],
		//autowidth:true,
		jsonReader: {
			root:"userList",
			page: "page",
			total: "page_count",
			records : "count",
			repeatitems: false
		},
		pager: jQuery("#userpage"),
		prmNames : {page:"page",sort: "sort"},
		rowNum: 10,
		//rowList: [10, 20, 30],
		sortname: 'uid',
		hidegrid: false,
		sortorder: 'asc',
		viewrecords: true,
		caption: '管理员',
		gridComplete:function(){
			var ids=jQuery("#userinfo").jqGrid('getDataIDs');
			for(var i=0; i<ids.length; i++){
				var id=ids[i]; 
				var bir = jQuery("#userinfo").jqGrid('getRowData', id).birthday;
				bir = bir.substring(0,10);
				
				var re = "<a href='javascript:;' class='jqtrow' onclick='modifyPwd(" + id + ")'>修改密码</a>"; 
				jQuery("#userinfo").jqGrid('setRowData', ids[i], { revoked: re,birthday:bir});
			}
		}
	}).navGrid("#userpage", { edit: false, add: false, del: false, search: false });
});	
</script>
<body style="background-color: #EEF2FB;">
    
    <div style="background-color: #EEF2FB;width: 100%;height: 700px;">	
				<div id="tabs">
					<ul>
						<li><a href="#tabs-1">管理员维护</a></li>
					</ul>
					<div id="tabs-1" style="height: 500px;">
						<div class="d_content">
							<button onclick="create()" style="margin-left: 850px;"
								class="b_maSel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
								role="button" aria-disabled="false">
								<span class="ui-button-text">新增管理员</span>
							</button>
							<!-- 表格 -->
							<div style="margin-left: 0px;margin-top: 0px;">
								<table id="userinfo"></table>
								<div id="userpage"></div>
							</div>
						</div>
						<!-- 修改密码弹出层 -->
						<div id="user_modifyPwd" style="display: none;" title="修改密码">
							<div class="dv1_main">
								<div class="dv1_name">帐号</div>
								<div class="dv1_val">
									<input id="account" type="text" readonly="readonly" />
								</div>
							</div>
							<div class="dv1_main">
								<div class="dv1_name">新密码</div>
								<div class="dv1_val">
									<input id="password" type="password"></input>
								</div>
							</div>
							<div class="dv1_main">
								<div class="dv1_name">确认密码</div>
								<div class="dv1_val">
									<input id="confirmPwd" type="password"></input>
								</div>
							</div>
						</div>
						<!-- 弹出层内容 新增管理员-->
						<div id="create_user" title="新增管理员" style="display: none;">
							<div class="d_scnOut" style="margin-top: 10px;">
								<div class="d_scname" style="font-size: 14px;">
									<label>帐号:</label>
								</div>
								<div class="d_sctext" style="font-size: 14px;">
									<input type="text" id="info_account" class="txt_scname">
								</div>
							</div>
							<div class="d_scnOut">
								<div class="d_scname" style="font-size: 14px;">
									<label>姓名:</label>
								</div>
								<div class="d_sctext" style="font-size: 14px;">
									<input type="text" id="info_realname" class="txt_scname">
								</div>
							</div>
							<div class="d_scnOut">
								<div class="d_scname" style="font-size: 14px;">
									<label>性别:</label>
								</div>
								<div class="d_male" style="font-size: 14px;">
									<input name="gender" type="radio" id="r_male" value="1"><label
										id="r_male_label" for="r_male">男</label>
								</div>
								<div class="d_female" style="font-size: 14px;">
									<input name="gender" type="radio" id="r_female" value="0"><label
										id="r_female_label" for="r_female">女</label>
								</div>
							</div>
		
							<div style="margin-top: -120px;margin-left: 270px;">
								<div class="d_scnOut">
									<div class="d_scname" style="font-size: 14px;">
										<label>密码:</label>
									</div>
									<div class="d_sctext" style="font-size: 14px;">
										<input type="password" id="info_password" class="txt_scname">
									</div>
								</div>
								<div class="d_scnOut">
									<div class="d_scname" style="font-size: 14px;">
										<label>昵称:</label>
									</div>
									<div class="d_sctext" style="font-size: 14px;">
										<input type="text" id="info_nikename" class="txt_scname">
									</div>
								</div>
								<div class="d_scnOut">
									<div class="d_scname" style="font-size: 14px;">
										<label>出生日期:</label>
									</div>
									<div class="d_sctext" style="font-size: 14px;">
										<input type="text" id="info_birthday" class="txt_scname"
											onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})"
											class="Wdate"><span id="span_birthday"> </span>
									</div>
								</div>
							</div>
						</div>
						
					</div>
				</div>
	</div>
</body>
<script type="text/javascript">
	$("#tabs").tabs();
	
	function modifyPwd(id) {
		var uid = jQuery("#userinfo").jqGrid('getRowData', id).uid;
		var account = jQuery("#userinfo").jqGrid('getRowData', id).account;
		$("#account").val(account);
		$("#user_modifyPwd").dialog({
			modal : true,
			resizable : false,
			height : 240,
			width : 300,
			buttons : {
				"确认" : function() {
				
				var password=$("#password");
				var passwordVal=password.val();
				if(isnull(passwordVal)){
					password.addClass("ui-state-error");
					$().message("请输入密码!");
					password.focus();
					return;
				}else{
					password.removeClass( "ui-state-error" );
				}
				var confirmPwd=$("#confirmPwd");
				var confirmPwdVal=confirmPwd.val();
				if (confirmPwdVal != passwordVal) {
					confirmPwd.addClass("ui-state-error");
					$().message("两次密码输入不一致，请重新输入!");
					confirmPwdVal.focus();
					return;
				}else{
					confirmPwd.removeClass( "ui-state-error" );
				}
				
				var fun = function(data) {
					if(1==data.s){
						$("#password").val("");
						$("#confirmPwd").val("");
						$().message("修改成功!");
						$("#user_modifyPwd").dialog("close");
					}else{
						$().message("修改失败,请稍后再试!");
					}
				};
				exeAjax(ajaxUrl("${aier_url}${aier_urijs}admin_user_modifyPwd${aier_suffix}"), fun, 
				{"uid" :uid,"password":passwordVal});
				}
			}
		});
	}
	// 创建管理员
	function create() {
		$("#create_user").dialog({
			modal : true,
			resizable : false,
			height : 300,
			width : 640,
			buttons : {
				"保存" : function() {
				
				var account=$("#info_account");
				var accountVal=account.val();
				if(isnull(accountVal)){
					account.addClass("ui-state-error");
					$().message("请输入帐号!");
					account.focus();
					return;
				}else{
					account.removeClass( "ui-state-error" );
				}
				var password=$("#info_password");
				var passwordVal=password.val();
				if(isnull(passwordVal)){
					password.addClass("ui-state-error");
					$().message("请输入密码!");
					password.focus();
					return;
				}else{
					password.removeClass( "ui-state-error" );
				}
				
				if ($('#r_female').attr("checked") == "checked") {
					var tsex = 0;
				} else {
					var tsex = 1;
				}
				
				var fun = function(data) {
					if(1==data.s){
						account.val("");
						password.val("");
						$("#info_realname").val("");
						$("#info_nikename").val("");
						$('#info_birthday').val("");
						$().message("创建成功，您还可以创建!");
						$("#userinfo").trigger("reloadGrid");
					}else{
						$().message("创建失败,请稍后再试!");
					}
				};
				exeAjax(ajaxUrl("${aier_url}${aier_urijs}admin_user_createUser${aier_suffix}"), fun, 
				{"account" :accountVal,
				 "password":passwordVal,
				 "realname":$("#info_realname").val(),
				 "nikename":$("#info_nikename").val(),
				 "sex":tsex,
				 "birthday":$('#info_birthday').val()});
				}
			}
		});
	}
</script>
</html>